<?php
namespace app\index\controller\user;
use app\index\model\UsersInfo;
class Info extends \app\index\controller\user\BaseUser{
    public function index(){
        $data = [];
        return view('user/info',$data);
    }
    public function save(){
        $request = \think\Request::instance();
        $data['nickname'] = $request->post('r_user');
        $data['email'] = $request->post('r_email');
        $data['name'] = $request->post('r_name');
        $data['sex'] = $request->post('sex');
        $data['phone'] = $request->post('r_tel');
        $data['city'] = $request->post('provinces');
        $data['birthday'] = $request->post('birthday');
        $data['relationship'] = $request->post('relationship');
        $data['birtd'] = $request->post('birtd');
        $data['favorite'] = $request->post('taste');

        foreach ($data as $key => $value) {
            if($value){
                //将修改的内容写到数据库中
                $users_info = new UsersInfo();
                $result = $users_info->where('users_id',$this->userdata['id'])->find();
                $result->$key = $value;               
                $result->save();
            }
        }

        //给出提示返回到当前页
        return $this->success('用户信息修改成功！','index/user.Info/save');
    }
    public function logout(){
        //删除Session
        \think\Session::delete('uid');
        //跳转到登录页面
        return $this->redirect('index/Index/index');        
    }





}